from fastapi import APIRouter,status,Form
from .models import UserIn, UserOut
from typing import Union, List



user = APIRouter()

@user.post("/response_model", response_model=UserOut, response_model_exclude_unset=True)
async def response_model(user: UserIn):
    print(user.password)
    return "1231231231"

@user.post("/response_model/attr",
           # response_model = Union[UserIn, UserOut]
           response_model= List[UserOut],
           # response_model_include=["username"],
           # response_model_exclude=["username"]

           )
async def response_attr(user: UserIn):
    del user.password
    return user

@user.post("/status_code", status_code=status.HTTP_200_OK)
async def status_attr():

    return {"status_code": status.HTTP_200_OK}


@user.post("/login")
async def status_attr(
        username: str = Form(...),
        password: str = Form(...)
):

    return {"username": username}